package com.arvin.controller;

import com.arvin.pojo.CommonResult;
import com.arvin.pojo.Users;
import com.arvin.service.UsersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Arvin
 * @date 2021/1/14
 **/
@RestController
@Slf4j      //日记
@RequestMapping("/provider")
public class UsersController {
    @Resource
    private UsersService usersService;

    @PostMapping("/add.action")
    public CommonResult add(Users users){
        int add = usersService.add(users);
        log.info("插入结果："+add);
        if (add>0){
            return new CommonResult(200,"添加数据成功！",add);
        }else{
            return new CommonResult(400,"添加失败！");
        }
    }

    @PostMapping("/login.action")
    public CommonResult login(Users users){
        List<Users> login = usersService.login(users);
        if (login!=null&& login.size()>0){
            return new CommonResult(200,"登录成功！",login);
        }else {
            return new CommonResult(400,"登录失败，查无此账号！");

        }
    }
}
